package com.kl.drs.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kl.drs.bean.bo.CheckResultBO;
import com.kl.drs.dao.CheckResultDAO;
import com.kl.drs.service.CheckResultService;
@Service("checkResultService")
public class CheckResultServiceImpl implements CheckResultService{
	@Autowired 
	private CheckResultDAO checkResultDAO;
	/**
	 * 新增返回结果查询
	 */
	@Override
	public String createOrUpdateCheckResult(CheckResultBO checkResultBO) {
		CheckResultBO param = new CheckResultBO();
		param.setBusinessNo(checkResultBO.getBusinessNo());
		CheckResultBO tmpResultBO = queryCheckResult(param);
		if(tmpResultBO !=null ){
			if(checkResultDAO.updateCheckResult(checkResultBO)>0){
				return "update";
			}else{
				return "fail";
			}
		}else{
			if(checkResultDAO.insertCheckResult(checkResultBO)>0){
				return "add";
			}else{
				return "fail";
			}
		}
	}
	/**
	 * 新增返回结果查询
	 */
	@Override
	public String createOrUndoCheckResult(CheckResultBO checkResultBO) {
		CheckResultBO param = new CheckResultBO();
		param.setBusinessNo(checkResultBO.getBusinessNo());
		param.setBankCode(checkResultBO.getBankCode());
		CheckResultBO tmpResultBO = queryCheckResult(param);
		if(tmpResultBO !=null ){
			return "update";
		}else{
			if(checkResultDAO.insertCheckResult(checkResultBO)>0){
				return "add";
			}else{
				return "fail";
			}
		}
	}
	/**
	 * 查询核心数据库中的数据
	 */
	@Override
	public CheckResultBO queryCheckResult(CheckResultBO checkResultBO) {
		
		return checkResultDAO.queryCheckResult(checkResultBO);
	}
	/**
	 * 查询列表信息
	 */
	@Override
	public List<CheckResultBO> getCheckResultList(String crs_salechnl) {
		return checkResultDAO.getCheckResultList(crs_salechnl);
	}
	/**
	 * 更新对账信息
	 */
	@Override
	public int updateCheckResult(CheckResultBO checkResultBO) {
		return checkResultDAO.updateCheckResult(checkResultBO);
	}

}
